home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10936 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.erinet.com!usenet
  2. From: timb@erinet.com (Tim Berens)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Determining the length of an int in string form
  5. Date: Wed, 20 Mar 1996 20:45:48 GMT
  6. Organization: EriNet Online 513 436-9915
  7. Message-ID: <4ipd9k$ep8@news.erinet.com>
  8. References: <3146D058.DD7@cbm.com> <4i7uth$qph@inet-nntp-gw-1.us.oracle.com> <DoE38u.GIH@iquest.net> <DoGs5D.FFB@iquest.net>
  9. NNTP-Posting-Host: edlp116.erinet.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. dlmiller@iquest.net (Doug Miller) wrote:
  13.  
  14.  
  15. >++] I have a variable of type int, and I would like to use the sprintf()
  16. >++] function to write this variable to a string.  However, I want to
  17. >++] dynamically allocate the space for the string, and only malloc enough
  18. >++] space to hold the int.
  19. >+
  20. >+WHY ???
  21. >+
  22. >+Even a 32-bit int is only 9 characters at most, and that's *with* the sign.  Why not just declare
  23. >+a string and be done with it?  Is storage space that tight for you, that nine bytes matters?
  24. >+
  25.  
  26. Maybe he needs to do this 50,000 times in a loop.  9 * 50,0000 bytes
  27. matters.
  28.  
  29.